@extends('layouts.tankuang')

@section('content')
        <form name="add_form" id="add_form" action="{{url('admin/units/add')}}" method="post" enctype="multipart/form-data" style="overflow-y: scroll;height:100%;">
            <input type="hidden" name="_token" value="{{ csrf_token() }}">
            <div id="div_print">
                <h2 class="text-center mg_b36 mg_t25" style="font-weight: bold;">企事业单位基本情况登记表</h2>
                <table class="table-form table-border w mg-auto">
                    <tbody>
                    <tr>
                        <td class="font-bd" align="center" width="16%">单位名称</td>
                        <td colspan="2"><input type="text" class="form-input w easyui-validatebox" value="" name="name" id="name" data-options="required:true,missingMessage:'请填写单位名称',validateOnCreate:false,validateOnBlur:true"></td>
                        <td rowspan="3" class="text-center">
                            <div class="box_bt">
                                <span class="img_add"><img src="../../css/icons/edit_add.png">添加单位图片</span>
                                <input class="box_file" type="file" name="pic">
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="font-bd" align="center">详细地址</td>
                        <td colspan="2"><input type="text" class="form-input w easyui-validatebox"  value="" name="address" data-options="required:true,missingMessage:'请填写详细地址',validateOnCreate:false,validateOnBlur:true"></td>
                    </tr>
                    <tr>
                        <td class="font-bd" align="center">辖区派出所</td>
                        <td colspan="2">
                            <div class="col-sm-3" style="margin-left: -15px;">
                                <select id="city" name="city" class="w150 input_all easyui-validatebox" style="width: 120px;" data-options="required:true,missingMessage:'请在列表中选择一项',validateOnCreate:false,validateOnBlur:true">
                                    <option value="">请选择</option>
                                    @foreach($city as $v)
                                        <option value="{{$v->id}}">{{$v->name}}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="col-sm-3" style="margin-left:15px;">
                                <select id="area" name="area" class="w150 input_all easyui-validatebox" style="width: 120px;" data-options="required:true,missingMessage:'请在列表中选择一项',validateOnCreate:false,validateOnBlur:true">
                                    <option value="">请选择</option>
                                </select>
                            </div>
                            <div class="col-sm-3" style="margin-left:15px;">
                                <select id="org_id" name="org_id" class="w150 input_all easyui-validatebox" style="width: 120px;" data-options="required:true,missingMessage:'请在列表中选择一项',validateOnCreate:false,validateOnBlur:true">
                                    <option value="">请选择</option>
                                </select>
                            </div>
                        </td>
                    </tr>
                    <tr><td colspan="4" style="background-color: #69CEE9;text-align: center">单位信息</td></tr>
                    <tr>
                        <td class="font-bd" align="center" width="16%">统一社会信用码</td>
                        <td width="34%">
                            <input type="text" class="form-input easyui-validatebox"  value="" name="zuzhijigou" data-options="required:true,missingMessage:'请输入18位统一社会信用码',validateOnCreate:false,validateOnBlur:true">（18位）
                        </td>
                        <td class="font-bd" align="center" width="16%">所属行业类别</td>
                        <td width="34%">
                            <select class="w153 input_all easyui-validatebox" name="type" id="type" data-options="required:true,missingMessage:'请选择行业类别',validateOnCreate:false,validateOnBlur:true">
                                <option value="">请选择行业类别</option>
                                @foreach($type as $k=>$v)
                                    <option value="{{$v->id}}">{{$v->name}}</option>
                                @endforeach
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td class="font-bd" align="center">重点级别</td>
                        <td>
                            <select class="w153 input_all easyui-validatebox" name="is_imp" data-options="required:true,missingMessage:'请选择重点级别',validateOnCreate:false,validateOnBlur:true">
                                <option value="">请选择重点级别</option>
                                <option value="10">省级重点单位</option>
                                <option value="20">市级重点单位</option>
                                <option value="30">县区级重点单位</option>
                                <option value="40">一般单位</option>
                            </select>
                        </td>
                        <td class="font-bd" align="center">单位性质</td>
                        <td>
                            <select id="area" name="xingzhi" class="w150 input_all easyui-validatebox" style="width: 120px;" data-options="required:true,missingMessage:'请选择单位性质',validateOnCreate:false,validateOnBlur:true">
                                <option value="">请选择单位性质</option>
                                <option value="10">国有</option>
                                <option value="20">民营</option>
                                <option value="30">股份</option>
                                <option value="40">合资</option>
                                <option value="50">外资</option>
                                <option value="60">个体</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td class="font-bd" align="center">上级部门</td>
                        <td>
                            <input type="text" class="form-input" name="shangjibumen" value="">
                        </td>
                        <td class="font-bd" align="center">单位状态</td>
                        <td>
                            <select class="w153 input_all easyui-validatebox" name="is_del" data-options="required:true,missingMessage:'请选择单位状态',validateOnCreate:false,validateOnBlur:true">
                                <option value="0">实有</option>
                                <option value="1">注销</option>
                                <option value="2">合并</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td class="font-bd" align="center">固定资产（万元）</td>
                        <td>
                            <input type="text" class="form-input" required="true" value="" name="gdzc">
                        </td>
                        <td class="font-bd" align="center">要害部门部位数量</td>
                        <td>
                            <input type="text" class="form-input" value="" disabled>
                        </td>
                    </tr>
                    <tr><td colspan="4" style="background-color: #69CEE9;text-align: center">人员信息</td></tr>
                    <tr>
                        <td class="font-bd" align="center">在职职工总数</td>
                        <td>
                            <input type="text" class="form-input" value="" name="zaizhi_num_of_peo">
                        </td>
                        <td class="font-bd" align="center">在职保安人数</td>
                        <td>
                            <input type="text" class="form-input" value="" disabled>
                        </td>
                    </tr>
                    <tr>
                        <td class="font-bd" align="center">自招保安人数</td>
                        <td>
                            <input type="text" class="form-input" value="" disabled>
                        </td>
                        <td class="font-bd" align="center">外聘保安人数</td>
                        <td>
                            <input type="text" class="form-input" value="" disabled>
                        </td>
                    </tr>
                    <tr>
                        <td class="font-bd" align="center">重点岗位人数</td>
                        <td>
                            <input type="text" class="form-input" value="" disabled>
                        </td>
                        <td class="font-bd" align="center">维稳对象人数</td>
                        <td>
                            <input type="text" class="form-input" value="" name="zdwwgzdx_num_of_peo">
                        </td>
                    </tr>
                    <tr>
                        <td class="font-bd" align="center">单位法人</td>
                        <td>
                            <input type="text" class="form-input easyui-validatebox" value="" name="frdb_name" data-options="required:true,missingMessage:'请填写单位法人',validateOnCreate:false,validateOnBlur:true">
                        </td>
                        <td class="font-bd" align="center">联系电话</td>
                        <td>
                            <input type="text" class="form-input easyui-validatebox" value="" name="frdb_phone" data-options="required:true,validType:'phoneAndMobile',missingMessage:'请填写联系电话',invalidMessage:'请输入正确的联系电话',validateOnCreate:false,validateOnBlur:true">
                        </td>
                    </tr>
                    <tr>
                        <td class="font-bd" align="center">保卫负责人</td>
                        <td>
                            <input type="text" class="form-input easyui-validatebox" value="" name="bwfzr_name" data-options="required:true,missingMessage:'请填写保卫负责人',validateOnCreate:false,validateOnBlur:true">
                        </td>
                        <td class="font-bd" align="center">联系电话</td>
                        <td>
                            <input type="text" class="form-input easyui-validatebox" value="" name="bwfzr_phone" data-options="required:true,validType:'phoneAndMobile',missingMessage:'请填写联系电话',invalidMessage:'请输入正确的联系电话',validateOnCreate:false,validateOnBlur:true">
                        </td>
                    </tr>
                    <tr><td colspan="4" style="background-color: #69CEE9;text-align: center">GIS信息</td></tr>
                    <tr>
                        <td class="font-bd" align="center">经度</td>
                        <td>
                            <input type="text" class="form-input easyui-validatebox" name="jd" value="" data-options="required:true,missingMessage:'请输入经度',validateOnCreate:false,validateOnBlur:true">
                        </td>
                        <td class="font-bd" align="center">纬度</td>
                        <td>
                            <input type="text" class="form-input easyui-validatebox" name="wd" value="" data-options="required:true,missingMessage:'请输入纬度',validateOnCreate:false,validateOnBlur:true">
                        </td>
                    </tr>
                    <tr>
                        <td class="font-bd" align="center">备注</td>
                        <td colspan="5">
                            <textarea class="textarea" name="remark"></textarea>
                        </td>
                    </tr>
                    </tbody>
                </table>

                <div class="wbt mg_t25 mg_b18">
                    <span class="font-bd" style="margin-left: 10px;">填报单位：</span>
                    <input type="text" class="w250 input_bottom dsp easyui-validatebox" name="tbdw" data-options="required:true,missingMessage:'请填写填报单位',validateOnCreate:false,validateOnBlur:true">
                    <span class="itv"></span>
                    <span class="font-bd">填报人：</span>
                    <input type="text" class="w250 input_bottom dsp easyui-validatebox" name="tbr" data-options="required:true,missingMessage:'请填写填报人',validateOnCreate:false,validateOnBlur:true">
                </div>

                <div class="wbt mg_t25 pd_b20 text-center">
                    <button id="go" type="button" class="easyui-linkbutton dsp"  data-options="iconCls:'icon-save'">确定</button>
                    <a id="goToPageB" class="easyui-linkbutton dsp print" data-options="iconCls:'icon-print'" onclick="getjwd()">点击获取经纬度</a>


                    @if(auth::user()->unit_id != '')
                    <button type="button" class="easyui-linkbutton dsp" data-options="iconCls:'icon-no'" onclick="$('#w').window('close')">关闭</button>
                    @endif
                </div>
            </div>
        </form>

         <div id="jwd" class="easyui-window" closed="true" title="新增" data-options="iconCls:'icon-save'" style="width:700px;height:500px;padding:10px;">




        <script type="text/javascript">


            $(document).on("change",'#city', function(){
                $('#area option:gt(0)').remove();
                $('#org_id option:gt(0)').remove();
                //alert(1);die;
                var cid = $("#city").val();
                var url = "{{url('admin/getArea')}}";
                $.getJSON(url,{cid:cid},function(json){
                    /*清空原有的选项*/
                    if(json != ''){
                        $.each(json,function(index,array){
                            var option = "<option value='"+array['id']+"'";
                            option += ">"+array['name']+"</option>";
                            $("#area").append(option);
                        });
                    }
                });
            });

            $(document).on("change",'#area', function(){
                $('#org_id option:gt(0)').remove();
                var cid = $("#area").val();
                var url = "{{url('admin/getArea')}}";
                $.getJSON(url,{cid:cid},function(json){
                    /*清空原有的选项*/
                    if(json != ''){
                        $.each(json,function(index,array){
                            var option = "<option value='"+array['id']+"'";
                            option += ">"+array['name']+"</option>";
                            $("#org_id").append(option);
                        });
                    }
                });
            });
        </script>


        @if(auth::user()->unit_id != '')
        <script>
            $('#go').click(function (){
            	if(!$("#add_form").form('validate')){
				return false;
				}
                var formData = new FormData($( "#add_form" )[0]);
                $.ajax({
                    type: "POST",
                    url: "{{url('admin/units/add')}}",
                    data: formData,
                    async: false,
                    cache: false,
                    contentType: false,
                    processData: false,

                    success: function(data) {
                        if(data.status == 1){
                            $.messager.alert('信息提示',data.msg,'info');
                            $('#w').dialog('close');
                            $('.pagination-load').click();
                        }else {
                            $.messager.alert('信息提示',data.msg,'info');
                        }
                    },
                    error: function(msg) {
                        var json=JSON.parse(msg.responseText);
                        $.each(json, function(index, value) {
                            $.messager.alert('信息提示',value,'info');die;
                        });
                    },
                });
            });
        </script>

        @else
        
          <script>
            $('#go').click(function (){
            	if(!$("#add_form").form('validate')){
				return false;
				}
                var formData = new FormData($( "#add_form" )[0]);
                $.ajax({
                    type: "POST",
                    url: "{{url('admin/units/add')}}",
                    data: formData,
                    async: false,
                    cache: false,
                    contentType: false,
                    processData: false,

                    success: function(data) {
                        if(data.status == 1){
                            window.location.href="http://nb.yntosite.com/admin/index";
                        }else {
                            $.messager.alert('信息提示',data.msg,'info');
                        }
                    }
                });
            });
        </script>

        @endif




        <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=hrVnXxLAGVr6QZ0rt9MaxU8bBkwKzyQC"></script>
    <script type="text/javascript">
        function getjwd(){
            $('#jwd').window({
                title: "获取经纬度",
                href: '/admin/units/getjwd',
                width:'700',
                height:'500',
                minimizable:false,
                top:($(window).height() - 500) * 0.5,
                left:($(window).width() - 700) * 0.5,
                modal:true,
                closed: false,
            });
        }
    </script>
@stop